#include "thread_pool.h"
#include <stdio.h>
#define STR_LEN 8   //盐值中的随机字符个数

//为MYSQL_BIND绑定输入参数
void bind_input(MYSQL_BIND * bind,enum enum_field_types bufftype, void* buffer,
                unsigned long* len, _Bool* is_null){
    bind->buffer_type = bufftype;
    bind->buffer = buffer;
    bind->length = len;
    bind->is_null = is_null;
}

//为MYSQL_BIND绑定输出参数
void bind_output(MYSQL_BIND * bind,enum enum_field_types bufftype, void* buffer,
                 unsigned long len){
    bind->buffer_type = bufftype;
    bind->buffer = buffer;
    bind->buffer_length = len;
}

void getsalt(char* salt_buf){
    char str[STR_LEN + 1] = {0};
    int i, flag;
    srand(time(NULL));
    for(i = 0; i < STR_LEN; i++){
        flag = rand() % 3;
        switch(flag){
        case 0:
            str[i] = rand() % 26 + 'a';
            break;
        case 1:
            str[i] = rand() % 26 + 'A';
            break;
        case 2:
            str[i] = rand() % 10 + '0';
            break;
        }
    }
    char salt[13] = {0};
    //将格式化的字符串写入salt
    sprintf(salt, "$6$%s$", str);
    strcpy(salt_buf, salt);
}

